﻿@{
    ViewBag.Title = "InquiryIndex";
}

<link href="~/Content/BootstrapSouce/css/bootstrap.css" rel="stylesheet" />
<script src="~/Content/BootstrapSouce/js/jquery.min.js"></script>
<script src="~/Content/BootstrapSouce/js/bootstrap.min.js"></script>
<script src="~/Content/EasyUI/jquery.min.js"></script>

<script>
    var Urls = window.location.href;
    var Sums = Urls.split("=");

    var projectNumber = Sums[1];
    $(function () {
        $.ajax({
            type: "get",
            url: "http://localhost:63805/apis/Inquiry/InquiryShow?name=" + projectNumber,
            success: function (obj)
            {
                $("#tds").empty();
                for (var i = 0; i < obj.length; i++)
                {
                    $("#tds").append("<tr><td>" + obj[i].inquiry_Id + "</td><td>" + obj[i].inquiry_UnitPrice + "</td><td>" + obj[i].inquiry_Content + "</td><td>" + obj[i].inquiry_Times + "</td></tr>");
                }
            }
        })

    })


    function InAdd()
    {
        var Urls = window.location.href;
        var Sums = Urls.split("=");

        var projectNumber = Sums[1];

        var inquiry_UnitPrice = $("#inquiry_UnitPrice").val();
        var inquiry_Content = $("#inquiry_Content").val();

        $.ajax({
            type: "post",
            url: "http://localhost:63805/apis/Inquiry/InquiryAdd",
            data: { projectNumber: projectNumber, inquiry_UnitPrice: inquiry_UnitPrice, inquiry_Content: inquiry_Content },
            success: function (obj)
            {
                if (obj > 0) {
                    alert("添加成功!");
                    location.href = '/Inquiry/InquiryIndex?id=' + projectNumber;
                }
                else {
                    alert("失败!");
                }
            }
        })

    }


</script>
<div class="col-md-12" style="margin-top:10px;height:40px;background-color:#0094ff">
    <input type="button" value="添加估价" data-toggle="modal" data-target="#modal_add_user" class="btn btn-primary" />
</div>


<table class=" table table-striped">
    <tr>
        <td>编号</td>
        <td>建议评估单价</td>
        <td>评估内容</td>
        <td>评估时间</td>
    </tr>
    <tbody id="tds">

    </tbody>
</table>

<div class="modal fade" id="modal_add_user" tabindex="-1" role="dialog" aria-labelledby="label_course">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="label_course"><strong>添加估价</strong></h4>
            </div>
            <div class="modal-body">
                <table class="table table-striped">
                    <tr>
                        <td>估计单价</td>
                        <td><input type="text" id="inquiry_UnitPrice" /></td>
                    </tr>
                    <tr>
                        <td>估价内容及其他</td>
                        <td><input type="text" id="inquiry_Content" /></td>
                    </tr>

                </table>
                <input type="button" value="添加" onclick="InAdd()" class="btn btn-success" />
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                </div>
            </div>
        </div>
    </div>
</div>
